
***************************************************************************************************************
* Description: Replicating results from Fleming, Thomas G. (2019) 'Partisan dealignment and committee power 
*              in five Westminster parliaments', European Journal of Political Research, 58:2, 536-556.
* Author:      Thomas G. Fleming																								 
* Date:        03/09/2019
* Note:        Data set up for analyses to take account of (twenty) imputed values of the dealignment variable,
*              and code calculates the mean Pseudo R-squared across the twenty estimations.
***************************************************************************************************************
 
  use "ejpr2019_replication.dta", clear

  tab country, gen(country_num)
  
***************************************************************************************************************
* Replicating models from Table 2: Negative binomial regressions of total committee numbers
***************************************************************************************************************
  
* Model 1

  mi estimate: nbreg committees dealignment_combined committees_lagged coalition minority workload country_num1 country_num2 country_num3 country_num4, vce(robust)
  
  mi query                            
  local M = r(M)
  scalar r2_p = 0
  quietly mi xeq 1/`M': nbreg committees dealignment_combined committees_lagged coalition minority workload country_num1 country_num2 country_num3 country_num4, vce(robust); scalar r2_p = r2_p + e(r2_p)
  scalar r2_p = r2_p/`M'
  di as txt "Pseudo R2 over imputed data = " as res r2_p

* Model 2
 
  mi estimate: nbreg committees dealignment_combined committees_lagged rile_range minority workload country_num1 country_num2 country_num3 country_num5, vce(robust) 

  mi query                          
  local M = r(M)
  scalar r2_p = 0
  quietly mi xeq 1/`M': nbreg committees dealignment_combined committees_lagged rile_range minority workload country_num1 country_num2 country_num3 country_num5, vce(robust); scalar r2_p = r2_p + e(r2_p)
  scalar r2_p = r2_p/`M'
  di as txt "Pseudo R2 over imputed data = " as res r2_p

***************************************************************************************************************
* Replicating incidence risk ratios from Table 3, based on Model 1 above
***************************************************************************************************************
  
* Repeating Model 1

  mi estimate: nbreg committees dealignment_combined committees_lagged coalition minority workload country_num1 country_num2 country_num3 country_num4, vce(robust)
  
* Calculating IRR for dealignment variable

  di exp(0.0109206) /*coefficient*/
  di exp(0.0043468) /*lower 95% CI*/ 
  di exp(0.0174944) /*upper 95% CI*/

* Calculating IRR for coalition variable

  di exp(-0.0185221) /*coefficient*/
  di exp(-0.1924013) /*lower 95% CI*/
  di exp(0.1553591) /*upper 95% CI*/

* Calculating IRR for minority variable

  di exp(-0.0308918) /*coefficient*/
  di exp(-0.1322117) /*lower 95% CI*/ 
  di exp(0.070428)  /*upper 95% CI*/

* Calculating IRR for workload variable

  di exp(0.0012263)  /*coefficient*/
  di exp(-0.002007) /*lower 95% CI*/ 
  di exp(0.0044596)   /*upper 95% CI*/
  
***************************************************************************************************************
* Replicating models from Table 4: Negative binomial regressions of increases/decreases in committee numbers
***************************************************************************************************************
  
 * use "ejpr2019_replication.dta", clear
 * tab country, gen(country_num)
  
* Model 3
  
  mi estimate: nbreg increase dealignment_combined coalition minority workload opposition_strength committees_lagged log_duration country_num1 country_num2 country_num3 country_num4, robust

  mi query                         
  local M = r(M)
  scalar r2_p = 0
  quietly mi xeq 1/`M': nbreg increase dealignment_combined coalition minority workload opposition_strength committees_lagged log_duration country_num1 country_num2 country_num3 country_num4, robust; scalar r2_p = r2_p + e(r2_p)
  scalar r2_p = r2_p/`M'
  di as txt "Pseudo R2 over imputed data = " as res r2_p   
  
* Model 4

  mi estimate: nbreg increase dealignment_combined rile_range minority workload opposition_strength committees_lagged log_duration country_num1 country_num2 country_num3 country_num4, robust

  mi query                           
  local M = r(M)
  scalar r2_p = 0
  quietly mi xeq 1/`M': nbreg increase dealignment_combined rile_range minority workload opposition_strength committees_lagged log_duration country_num1 country_num2 country_num3 country_num4, robust; scalar r2_p = r2_p + e(r2_p)
  scalar r2_p = r2_p/`M'
  di as txt "Pseudo R2 over imputed data = " as res r2_p   
 
* Model 5
 
  mi estimate: nbreg decrease dealignment_combined coalition minority workload opposition_strength committees_lagged log_duration country_num1 country_num2 country_num3 country_num4, robust

  mi query                          
  local M = r(M)
  scalar r2_p = 0
  quietly mi xeq 1/`M': nbreg decrease dealignment_combined coalition minority workload opposition_strength committees_lagged log_duration country_num1 country_num2 country_num3 country_num4, robust; scalar r2_p = r2_p + e(r2_p)
  scalar r2_p = r2_p/`M'
  di as txt "Pseudo R2 over imputed data = " as res r2_p
 
* Model 6

  mi estimate: nbreg decrease dealignment_combined rile_range minority workload opposition_strength committees_lagged log_duration country_num1 country_num2 country_num3 country_num4, robust

  mi query                          
  local M = r(M)
  scalar r2_p = 0
  quietly mi xeq 1/`M': nbreg decrease dealignment_combined rile_range minority workload opposition_strength committees_lagged log_duration country_num1 country_num2 country_num3 country_num4, robust; scalar r2_p = r2_p + e(r2_p)
  scalar r2_p = r2_p/`M'
  di as txt "Pseudo R2 over imputed data = " as res r2_p
  
***************************************************************************************************************

clear
